<?php 
$cs = Yii::app()->getClientScript();
$cs->registerCssFile('css/reg.log.css');
?>
<?php

/**
 * @param $action
 * @param boolean $ajax
 */
//init param
$ajax = isset ($ajax) ? $ajax : true;
$model = isset ($model) ? $model : new RegisterForm;

$form=$this->beginWidget('CActiveForm', array(
	'id'=>'register-form',
	'action'=>array('/user/register'), 
	'enableAjaxValidation'=>$ajax,
	'clientOptions'=>array('validateOnSubmit'=>true,
	),
	'focus'=>'input:text[value=""]:first',
	'htmlOptions'=>array('class'=>'reg-login')
	
)); 

$labels = $model->attributeLabels(); 
?>
 <center>
  <table style="width:800px;" align='center'>
  	<tr>
  		<td>
  		<div>
		<?php echo $form->textField($model,'email',array('class'=>'input','label'=>$labels['email'],'autocomplete'=>'off')); ?>
 		</div>
		<?php echo $form->error($model,'email'); ?></td>
  		<td>
		<div><?php echo $form->passwordField($model,'password',array('class'=>'input','label'=>$labels['password'],'autocomplete'=>'off')); ?>
 		 </div>
		<?php echo $form->error($model,'password'); ?></td>
  		<td>
  		<div><span id = 'domain_hint'>http://MR8.me/</span><?php echo $form->textField($model,'domain',array('class'=>'input','label'=>$labels['domain'],'autocomplete'=>'off','onKeyup'=>"value=value.replace(/^[^A-Za-z]+/g,'');value=value.replace(/[^A-Za-z0-9]/g,'')")); ?>
		</div>
		<?php echo $form->error($model,'domain'); ?></td>
  		<td>
		<?php echo CHtml::submitButton('注册',array('class'=>'button')); ?></td>
  	
  	</tr>
  
  </table> 
</center>
<?php $this->endWidget(); ?>
<script>


$(function(){
	var form_init = function(){
		
		$('form#register-form input.input').each(function(){
			
	//		$(this).addClass('backTip').attr('value',$(this).attr('label'));
			var name = $(this).attr('id');
			var pos = $(this).position();
			
			var tip = $('#'+name+'_tip');
			if(tip.length == 0){
				tip = $('<span/>').attr('id',name+'_tip').text($(this).attr('label')).addClass('backTip')
				.appendTo($(this).parent());
				tip.mouseover(function(){$(this).hide();});
		
				$(this).mouseover(function(){
						$(this).focus();
					}).mouseout(function(){
						$(this).blur();
					}) .focus(function(){
						$(this).click();
						tip.hide();
					}).blur(function(){
						if($(this).attr('value') =='' ){
							$(this).parent('div.error').removeClass('error');
							tip.show();
						}
		
					});
			}
			tip.css({position:'absolute',left:pos.left+'px',top:pos.top+'px'});
			
		});
		
	};
	$(window).bind('load',form_init).bind('resize',form_init);
	
});


</script>